package tool

import (
	"encoding/json"
	"fmt"
)

func TansferMapRet(ww interface{}, ss string) interface{} {
	t, _ := ww.(map[string]interface{})
	for k, v := range t {
		switch v2 := v.(type) {
		case map[string]interface{}:
			if k == ss {
				zz := v2
				return zz
			}
		case []interface{}:
			if k == ss {
				zz := v2
				return zz
			}
		case string:
			if k == ss {
				zz := v2
				return zz
			}
		case int:
			if k == ss {
				zz := v2
				return zz
			}
		}
	}
	return nil
}

func InterfaceToString(a interface{}) string {
	b, _ := a.(string)

	return b
}

func InterfaceToList(a interface{}) []interface{} {
	b, _ := a.([]interface{})
	return b
}
func UnmarshalJson(uu []byte) interface{} {
	var r interface{}
	err := json.Unmarshal(uu, &r)
	if err != nil {
		fmt.Println(err)
	}
	return r

}
